using System.Collections.Generic;

namespace Engine.FileFormats3D.WR2TrafficFiles
{
    public class SpeedBlockFileBlock
    {
        #region Private Fields

        private List<SpeedBlock> speedBlocks = new List<SpeedBlock>();

        #endregion Private Fields

        #region Public Methods

        public short Count()
        {
            return (short)speedBlocks.Count;
        }

        public int GetSpeedBlockID(byte speed, short shapeID)
        {
            for (int i = 0; i < this.speedBlocks.Count; i++)
            {
                if (this.speedBlocks[i].Speed == speed &&
                    this.speedBlocks[i].ShapeID == shapeID)
                {
                    return i;
                }
            }
            this.speedBlocks.Add(new SpeedBlock(shapeID, speed));
            return speedBlocks.Count - 1;
        }

        public void Save(System.IO.BinaryWriter bw)
        {
            foreach (SpeedBlock sb in this.speedBlocks)
            {
                sb.Save(bw);
            }
        }

        #endregion Public Methods
    }
}